import java.util.ArrayList;

public class main {
	
	
	public static void main(String args[]) {
		int[] networkCode;
		BaseStation baseStation;
		ArrayList<Receiver> receiversList;
		
		//generation randomly network code
		networkCode = new int[3];
		for(int i=0; i<3;i++){
			networkCode[i] = (int) (Math.random() * (2));		
		}
		
		int nbReceivers = 4;
		int lenghtChips = 128;
		int lenghtMessage = 128;
		int percentageError = 7;
		

		System.out.println("Number of Receivers : ");
		nbReceivers = Lire.jint();
		
		/*System.out.println("Length of the chips : ");
		nbReceivers = Lire.jint();
		
		System.out.println("Percentage Error : ");
		percentageError = Lire.jint();
		*/
		
		//Creation base station
		
		receiversList = new ArrayList<Receiver>();
		
		
		baseStation = new BaseStation(nbReceivers, lenghtChips, lenghtMessage, networkCode, receiversList, percentageError); 
		//System.out.println("baseStation Created");
		usersCreation(nbReceivers, baseStation, receiversList, networkCode, lenghtChips, lenghtMessage);
		//System.out.println("users Created");
		baseStation.run();	
	}
	
	
	public static void usersCreation(int nbReceivers, BaseStation basestation, ArrayList<Receiver> receiversList, int[] networkCode, int lenghtChips, int lenghtMessage){
		//creation of receivers
		for(int i=0; i<nbReceivers; i++){
			receiversList.add(new Receiver(networkCode, basestation.getCellCode(), basestation.getOVSFCode(basestation.getHadamardInitialMatrix()), basestation.getGoldCode(), lenghtChips, lenghtMessage, nbReceivers, basestation));
			
			//receiversList.get(i).start();
			//System.out.println(receiversList.get(i).toString());
		}
		receiversList.get(0).start();
		
	}
}
